package net.cjw.initsb.utils;

import javax.servlet.http.HttpSession;

public class SessionUtil {

	private static int day = 86400;

	public static void setLoginUid(HttpSession session, String uid, Integer time) {
		session.setAttribute("uid", uid);
		if (time == null) {
			session.setMaxInactiveInterval(day * 7);
		} else {
			session.setMaxInactiveInterval(time);
		}
	}

	public static String getLoginUid(HttpSession session) {
		return (String) session.getAttribute("uid");
	}

	public static void logout(HttpSession session) {
		session.removeAttribute("uid");
	}

}
